|
|
|
|
|
|
|
Solution 26
Universal Identifiers, Part 2 |
|
|
|
|
|
|
|
|
If you uncommented the Err.Raise code in the GUIDObject class, the program would be as follows: |
|
|
|
 |
|
|
|
|
res = CLSIDFromProgID(MyProgramId, cid)
If res = 0 Then
GetCLSID = cid
Else
' What happens when you uncomment this?
Err.Raise res
End If |
|
|
|
|
|
|
|
|
Since when do you raise errors with results from API functions? Normally, you would use the GetErrorString function in ErrString.bas to retrieve a text description of an error. |
|
|
|
|
|
|
|
|
Let's take another look at the CLSIDFromProgID function documentation and VB declaration: |
|
|
|
|
|
|
|
|
HRESULT CLSIDFromProgID( LPCOLESTR lpszProgID, //Pointer to the ProgID
LPCLSID pclsid //Pointer to the CLSID
); Private Declare Function CLSIDFromProgID Lib "ole32.dll" _
(ByVal lpszProgId As String, lpclsid As CLSID) As Long |
|
|
|
|
|
|
|
|
What is an HRESULT? According to the declaration, it is a Long value, which is what you would expect given that API functions almost always return Long values. |
|
|
|
|
|
|
|
|
If you look in the definition of HRESULT in the wtypes.h file, you'll see the following: |
|
|
|
|
|